﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Kevin.Controls
{
    /// <summary>
    /// 操作命令项
    /// </summary>
    public class CommandItem
    {
        public CommandItem()
        {
 
        }
        /// <summary>
        /// 按钮控件ID
        /// </summary>
        public string ControlID
        {
            get;
            set;
        }
        /// <summary>
        /// WebService方法名
        /// </summary>
        public string ServiceMethod
        {
            get;
            set;
        }
        /// <summary>
        /// 命令参数
        /// </summary>
        public string CommandType
        {
            get;
            set;
        }
        private bool _isValidate = true;
        /// <summary>
        /// 是否触发校验事件
        /// </summary>
        public bool IsValidate
        {
            get { return _isValidate; }
            set { _isValidate = value; }
        }
        /// <summary>
        /// 命令执行之前需调用的方法(该方法必须返回true/false)
        /// </summary>
        public string OnOperationPre
        {
            get;
            set;
        }
        /// <summary>
        /// 命令执行后的回调方法(Javascript)
        /// </summary>
        public string CallbackMethod
        {
            get;
            set;
        }
    }

    /// <summary>
    /// 操作命令集合类
    /// </summary>
    public class CommandItemCollection : CollectionBase
    {
        public void Add(CommandItem item)
        {
            if (item != null)
                base.List.Add(item);
        }

        public CommandItem this[int index]
        {
            get { return (CommandItem)List[index]; }
            set { List[index] = value; }
        }



        public bool Contains(string ControlID)
        {
            foreach (CommandItem item in this)
            {
                if (item.ControlID == ControlID)
                    return true;
            }
            return false;
        }
    }
}
